﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Irony.Ast;
using Irony.Interpreter;
using Irony.Parsing;

namespace ConciseMarkupLanguage.Ast
{
    class FilterNode : AstNode
    {
        public string Function;

        public override void Init(ParsingContext context, ParseTreeNode treeNode)
        {
            base.Init(context, treeNode);
            AsString = Function = treeNode.ChildNodes[0].FindTokenAndGetText();
            if (treeNode.ChildNodes.Count > 1)
                AddChild("arg", treeNode.ChildNodes[1]);
        }

        public override void EvaluateNode(EvaluationContext context, AstMode mode)
        {
            foreach (var node in ChildNodes)
            {
                node.Evaluate(context, AstMode.Read);
            }
        }
    }
}
